<?php
$width=Yii::app()->params['dialog']['findTruckBoardForMaintenance']['width'];
$height=Yii::app()->params['dialog']['findTruckBoardForMaintenance']['height'];
$width1=Yii::app()->params['dialog']['findTruckForMaintenance']['width'];
$height1=Yii::app()->params['dialog']['findTruckForMaintenance']['height'];
$width2=Yii::app()->params['dialog']['findDriverForMaintenance']['width'];
$height2=Yii::app()->params['dialog']['findDriverForMaintenance']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$str=<<<END
function Block(){
var title; var kind=$("#Ordinary_maintenance_kind").val();
if(kind==0) title="请选择车辆"; else title="请选择尾板";
 \$.modal('?r=dialog/findTruckBoardForMaintenance&kind='+kind,{width:$width,height:$height,title:title});return false;}
function Block1(){\$.modal('?r=dialog/findTruckForMaintenance',{width:$width1,height:$height1,title:'请选择车辆'});return false;}
function Block2(){\$.modal('?r=dialog/findDriverForMaintenance',{width:$width2,height:$height2,title:'请选择司机'});return false;} 
$("#findTruckBoard").click(Block);
$("#findTruck").click(Block1);
$("#findDriver").click(Block2);
$("#Ordinary_maintenance_kind").change(function(){\$("#Ordinary_maintenance_reg_no").val('');$("#Ordinary_maintenance_maintain_reg_no").val('');$("#Ordinary_maintenance_maintain_plate_no").val('');$("#Ordinary_maintenance_fk_maintain_truck_id").val('');$("#Ordinary_maintenance_fk_truck_id").val('');$("#Ordinary_maintenance_plate_no").val('');kind_sel();});
var attr=[];
$("[id*=tyre]").each(function(i,item){attr.push($(item).removeAttrs('class my_number my_float maxlength'));});
$("[id*=tyre]").each(function(i,item){\$(item).attr(attr[i]);});
function sel1(){
	var s1=$("#Ordinary_maintenance_mean_item");
	var n=s1.val();
	var s2=$("#Ordinary_maintenance_smallest_item");
	if(has[n]!=null){
		s2.show();
		s2[0].options.length=0;
		for(var i=0;i<has[n].length;i++){
			var varItem = new Option(sel2[has[n][i]],has[n][i]);
			s2[0].options.add(varItem);
		}
		for(var i=0;i<s2[0].length;i++) if(s2[0].options[i].value=={$model->smallest_item}) s2[0].options[i].selected=true;
	}else{s2.hide();}
	if(s1.val()==0)	{\$("#tyre").show(500);$("[id*=tyre]").each(function(i,item){\$(item).attr(attr[i]);});}
	else {\$("#tyre").hide();$("[id*=tyre]").each(function(i,item){\$(item).removeAttrs('class my_number my_float maxlength');$(item).removeClass('error').val('').next('span[class=error]').remove();});}
}
function kind_sel(){\$('#Ordinary_maintenance_kind').val()==0?$('#findTruck').hide():$('#findTruck').show();}
$("#Ordinary_maintenance_mean_item").change(sel1);
sel1(); kind_sel();
END;
$cs->registerScript('truck_verification_dialog',$model->getMeanItemHasNum().$str);
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa" >
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'kind'); ?>
<?php echo EHtml::activeDropDownList($model,'kind',$model->getKindNames()); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'driver_name'); ?>
<?php echo EHtml::activeTextField($model,'driver_name',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
<?php echo CHtml::activeHiddenField($model,'fk_driver_id');?>&nbsp;&nbsp;<a id="findDriver" href="#">查找司机</a>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'odometer_count'); ?>
<?php echo EHtml::activeTextField($model,'odometer_count',array('size'=>7)); ?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'max_item'); ?>
<?php echo EHtml::activeDropDownList($model,'max_item',$model->getMaxItemNames()); ?>
</div>
<div class="simple" >
<?php echo CHtml::activeLabelEx($model,'mean_item'); ?>
<?php echo EHtml::activeDropDownList($model,'mean_item',$model->getMeanItemNames()); ?>
<?php echo EHtml::activeDropDownList($model,'smallest_item',array());?>
</div>
</div>
  <div id="rightaa">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'maintain_plate_no'); ?>
<?php echo EHtml::activeTextField($model,'maintain_plate_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
<?php echo CHtml::activeHiddenField($model,'fk_maintain_truck_id');?>&nbsp;&nbsp;<a id="findTruckBoard" href="#">查找车辆/尾板</a>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'maintain_reg_no'); ?>
<?php echo EHtml::activeTextField($model,'maintain_reg_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
<?php echo CHtml::activeHiddenField($model,'fk_truck_id');?>&nbsp;&nbsp;<a id="findTruck" href="#">查找车辆</a>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'reg_no'); ?>
<?php echo EHtml::activeTextField($model,'reg_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
</div>
<div class="simple" >
</div>
</div>
<div id="tyre">
<div id="leftaa" style=" border-top:0px;">
<div class="simple1"style=" border-top:0px;">
<?php echo CHtml::activeLabelEx($model,'tyre_name'); ?>
<?php echo EHtml::activeTextField($model,'tyre_name',array('class'=>'required','maxlength'=>30)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'tyre_position'); ?>
<?php echo EHtml::activeDropDownList($model,'tyre_position',$model->getTyrePositionNames());?>
</div>
<div class="simple1"  style=" border-bottom:0px;">
<?php echo CHtml::activeLabelEx($model,'tyre_type'); ?>
<?php echo EHtml::activeDropDownList($model,'tyre_type',$model->getTyreTypeNames());?>
</div>
</div>
  <div id="rightaa"style=" border-top:0px;">
<div class="simple1"style=" border-top:0px;">
<?php echo CHtml::activeLabelEx($model,'tyre_sum'); ?>
<?php echo EHtml::activeTextField($model,'tyre_sum',array('class'=>'required','my_number'=>true,'size'=>7)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'tyre_unit_price'); ?>
<?php echo EHtml::activeTextField($model,'tyre_unit_price',array('class'=>'required','my_float'=>16.2,'size'=>7)); ?>
</div>
<div class="simple1"  style=" border-bottom:0px;">
</div>
</div>
<div class="simple4">
<?php echo CHtml::activeLabelEx($model,'tyre_no'); ?>
<?php echo EHtml::activeTextArea($model,'tyre_no',array('class'=>'required','rows'=>6,'cols'=>65,'maxlength'=>500)); ?>
</div>

</div><!--end tyre-->
<div id="leftaa" style=" border-top:0px;">
<div class="simple1" style=" border-top:0px;">
<?php echo CHtml::activeLabelEx($model,'maintain_co'); ?>
<?php echo EHtml::activeTextField($model,'maintain_co',array('size'=>20,'maxlength'=>100)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'maintain_date'); ?>
<?php echo EHtml::activeTextField($model,'maintain_date',array('id'=>'maintain_date','size'=>10)); ?>
<?php $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'maintain_date','ifFormat'=>'%Y-%m-%d',));?>
</div>
</div>
  <div id="rightaa" style=" border-top:0px;">
<div class="simple1" style=" border-top:0px;" >
<?php echo CHtml::activeLabelEx($model,'maintain_cost'); ?>
<?php echo EHtml::activeTextField($model,'maintain_cost',array('size'=>7)); ?>
</div>
<div class="simple" >
</div>
</div>
<div class="simple4">
<?php echo CHtml::activeLabelEx($model,'remark'); ?>
<?php echo EHtml::activeTextArea($model,'remark',array('class'=>'required','rows'=>6,'cols'=>65,'maxlength'=>500)); ?>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>